package com.sjb.singleSingleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created with IntelliJ IDEA.
 * 懒汉模式中的单例模式
 * @Author: 有点儿意思
 * @Description:
 */
public class LazyManSingleton {


    private AtomicLong id = new AtomicLong(0);

    private static LazyManSingleton inStance;

    private LazyManSingleton(){}

    public static synchronized LazyManSingleton getInstance(){
        if (inStance == null){
            inStance = new LazyManSingleton();
        }
        return inStance;
    }

    public long getId(){
        return id.incrementAndGet();
    }
}
